﻿using System;
using System.Collections.Generic;
using System.Text;
using Gammar.Price.ObjectModel;
using Gammar.Price.DataAccess;
using Gammar.Price.Utility.Configuration;
using System.ComponentModel;

namespace Gammar.Price.Business
{
    /// <summary>
    /// 全局查找业务类
    /// </summary>
    [DataObject(true)]
    public static class SearchLogic
    {
        /// <summary>
        /// 通过用户输入的关键字和页码来查找
        /// </summary>
        /// <param name="keyWord"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public static Sp_SearchEntity[] RetrieveSearchItem(string keyWord, int pageIndex)
        {
            Sp_Search sp = new Sp_Search(keyWord, pageIndex, 10);
            return sp.Execute(DatabaseManager.Instance.CurrentDBAccess);
        }

        public static SearchContentEntity RetrieveSearchItemByKey(Guid guid)
        {
            if (guid == null)
                throw new ArgumentNullException("guid");

            SearchContent sc = new SearchContent();
            return sc.RetrieveItemByKey(guid, DatabaseManager.Instance.CurrentDBAccess);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public static Sp_RecommandItemEntity[] RetrieveRecommandItemsByKey(Guid guid)
        {
            if (guid == null)
                throw new ArgumentNullException("guid");

            Sp_RecommandItem sp = new Sp_RecommandItem(guid);
            return sp.Execute(DatabaseManager.Instance.CurrentDBAccess);
        }
    }
}
